package com.accounting.client.frontend.product.handlers;

import com.accounting.client.frontend.product.UpdatePurchaseRecordPanel;
import com.accounting.client.remote.obj.PurchaseRecord;
import com.google.gwt.user.client.ui.Widget;

import corelib.client.delegate.Action;
import corelib.client.ui.widget.Size;
import corelib.client.ui.widget.WindowHandle;
import corelib.client.ui.widget.button.IsButton;
import corelib.client.ui.widget.dialog.SimpleDialogHandler;

public class UpdatePurchaseRecordHandler extends SimpleDialogHandler {

	private PurchaseRecord record;
	private Action action;
	
	public UpdatePurchaseRecordHandler(PurchaseRecord purchaseRecord, Action action) {
		this.record = purchaseRecord;
		this.action = action;
	}
	
	@Override
	public Widget getContentPanel() {
		return new UpdatePurchaseRecordPanel(record, new Action() {
			@Override
			public void run() {
				action.run();
				closeDialog();
			}
		}).getWidget();
	}

	@Override
	public String getHeading() {
		return "更新购买记录";
	}

	@Override
	public Size getSize() {
		return new Size(1050, 450);
	}

	@Override
	public IsButton[] getButtons() {
		return new IsButton[0];
	}

	@Override
	public void onClosing(WindowHandle windowHandle) {
		windowHandle.close();
	}

}
